﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace SpaceshipDuel
{
    public enum UpgadeTypes
    {
        Weapon          = 0,    // SingleShot -> DoubleShot -> TripleShot -> FiveShot
        Speed           = 1,    // schnellere Fluggeschwindigkeit und Rotationsgeschwindigkeit
        ShieldRefresh   = 2,    // Schild komplett aufladen
        Special         = 3     // Spezialwaffe
    }

    public class Upgrade : GameObject
    {
        #region Private fields
    
        bool destroyMe;      // Flag zum Löschen 
        UpgadeTypes type;    // Typ des Upgrades

        #endregion Private fields

        #region Public properties

        public bool DestroyMe
        {
            get { return this.destroyMe; }
            set { this.destroyMe = value; }
        }

        public UpgadeTypes Type
        {
            get { return this.type; }
            set { this.type = value; }
        }

        #endregion Public properties

        #region Construction

        /// <summary>
        /// Konstruktor
        /// </summary>
        /// <param name="newTexture"></param>
        /// <param name="newPosition"></param>
        /// <param name="newType"></param>
        public Upgrade(TextureData newTextureData, Vector2 newCenter, UpgadeTypes newType)
        {
            textureData = newTextureData;
            center = newCenter;
            type = newType;
            destroyMe = false;
        }

        #endregion Construction

        #region Public methods

        /// <summary>
        /// Update-Methode für den Schuss
        /// </summary>
        new public void Update()
        {
        }

        /// <summary>
        /// Draw-Methode für den Schuss
        /// </summary>
        /// <param name="spriteBatch">Spritebacth</param>
        /// <param name="xOffset">Offset X</param>
        /// <param name="yOffset">Offset Y</param>
        new public void Draw(SpriteBatch spriteBatch, float xOffset, float yOffset)
        {
            if (destroyMe == false)
            {
                Rectangle destRect = new Rectangle((int)(center.X - textureData.tileWidth / 2 + xOffset), (int)(center.Y - textureData.tileHeight / 2 + yOffset), textureData.tileWidth, textureData.tileHeight);

                switch (type)
                {       
                    case UpgadeTypes.Weapon:
                        spriteBatch.Draw(textureData.texture, destRect, new Rectangle(textureData.tileWidth, 0, textureData.tileWidth, textureData.tileHeight), Color.White);
                        break;
                    case UpgadeTypes.Speed:
                        spriteBatch.Draw(textureData.texture, destRect, new Rectangle(2 * textureData.tileWidth, 0, textureData.tileWidth, textureData.tileHeight), Color.White);
                        break;
                    case UpgadeTypes.ShieldRefresh:
                        spriteBatch.Draw(textureData.texture, destRect, new Rectangle(0, 0, textureData.tileWidth, textureData.tileHeight), Color.White);
                        break;
                    case UpgadeTypes.Special:
                        spriteBatch.Draw(textureData.texture, destRect, new Rectangle(3 * textureData.tileWidth, 0, textureData.tileWidth, textureData.tileHeight), Color.White);
                        break;
                }      
            }
        }

        #endregion Public methods
    }
}
